<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>将数字字符转化为数字以参与数学运算</title>
</head>
<body>
    <script>
        var price = "123.5";
        var num = "8";
        var amount;

        amount = parseFloat(price) * parseInt(num);
        window.alert("您购买的商品单价为" + price + "元，您将有购买" + num + "个，金额为" + amount + "元。");
    </script>
</body>
</html>
